package com.thoughtful.registry.zk;

import java.net.InetSocketAddress;

import com.thoughtful.registry.ServiceRegister;
import com.thoughtful.registry.zk.util.CuratorUtils;
import org.apache.curator.framework.CuratorFramework;

/**
 * @author yushun
 * @createTime 2022/10/19 - 14:45
 **/
public class ZkServiceRegistryImpl implements ServiceRegister {

    @Override
    public void registerService(String rpcServiceName, InetSocketAddress inetSocketAddress) {
        String servicePath = CuratorUtils.ZK_REGISTER_ROOT_PATH  + "/" + rpcServiceName + inetSocketAddress.toString();
        CuratorFramework zkClient = CuratorUtils.getZkClient();
        CuratorUtils.createPersistentNode(zkClient, servicePath);
    }

}
